<template>
  <base-option :selected="selected" :field-config="fieldConfig" :form-config="formConfig">
    <template #default="{ hideOptions }">
      <option-items
        v-if="fieldConfig.optionItems !== undefined"
        :selected="selected"
        :field-config="fieldConfig"
        :form-config="formConfig"
        multiple
      />
      <el-form-item v-if="fieldConfig.ellipsis !== undefined && hideOptions('ellipsis')" label="显示省略号">
        <el-switch v-model="fieldConfig.ellipsis" size="default" />
      </el-form-item>
      <el-form-item v-if="fieldConfig.collapseTags !== undefined && hideOptions('collapseTags')" label="折叠标签">
        <el-switch v-model="fieldConfig.collapseTags" size="default" />
      </el-form-item>
      <el-form-item v-if="hideOptions('maxCollapseTags')" label="显示标签数量">
        <el-input-number
          v-model="fieldConfig.maxCollapseTags"
          :disabled="!fieldConfig.collapseTags"
          :min="1"
          :max="20"
          controls-position="right"
        />
      </el-form-item>
    </template>
  </base-option>
</template>

<script setup>
import { toRefs } from 'vue'
import baseOption from './base-option.vue'
import optionItems from '../option-items.vue'
import propsDefinition from './props'
const props = defineProps(propsDefinition)
const { selected, fieldConfig, formConfig } = toRefs(props)
</script>
